local duohuo = fk.CreateSkill {
  name = "th_duohuo",
  max_round_use_time = 2,
}

duohuo:addEffect(fk.CardUseFinished, {
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(duohuo.name) and target and target:isAlive() and data.card and
    player.room:getCardArea(data.card) == Card.Processing and data.card.is_damage_card
  end,
  on_cost = function(self, event, target, player, data)
    local prompt = "#th_duohuo-invoke"
    if target and target ~= player then
      prompt = "#th_duohuo-invoke_other:" .. target.id
    end
    return player.room:askToSkillInvoke(player, {
      skill_name = duohuo.name,
      prompt = prompt
    })
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if target == player then
      room:notifySkillInvoked(player, duohuo.name, "support")
    else
      room:notifySkillInvoked(player, duohuo.name, "offensive")
    end
    room:obtainCard(target, data.card, true, fk.ReasonPrey, player.id, duohuo.name)
    for _, cid in ipairs(Card:getIdList(data.card)) do
      room:setCardMark(Fk:getCardById(cid), "@@th_duohuo-turn", 1)
    end
    if target:isAlive() and target ~= player then
      room:damage{
        from = player,
        to = target,
        damage = 1,
        damageType = fk.FireDamage,
        skillName = duohuo.name,
      }
    end
  end
}, { check_skill_limit = true })
duohuo:addEffect("prohibit", {
  prohibit_use = function(self, player, card)
    if card then
      for _, id in ipairs(Card:getIdList(card)) do
        if Fk:getCardById(id):getMark("@@th_duohuo-turn") ~= 0 then
          return true
        end
      end
    end
  end,
  prohibit_response = function(self, player, card)
    if card then
      for _, id in ipairs(Card:getIdList(card)) do
        if Fk:getCardById(id):getMark("@@th_duohuo-turn") ~= 0 then
          return true
        end
      end
    end
  end
})
duohuo:addEffect("maxcards", {
  name = "#th_duohuo_maxcard",
  exclude_from = function(self, player, card)
    return card:getMark("@@th_duohuo-turn") ~= 0
  end
})

Fk:loadTranslationTable{
  ["th_duohuo"] = "堕火",
  [":th_duohuo"] = "每轮限两次，一名角色使用伤害牌后，你可以令其获得之，若该角色不为你，你对其造成1点火焰伤害；以此法获得的牌本回合不能使用或打出且不计入手牌上限。",

  ["#th_duohuo-invoke"] = "堕火：你可以获得此牌（以此法获得的牌本回合不能使用或打出且不计入手牌上限）",
  ["#th_duohuo-invoke_other"] = "堕火：你可以令 %src 获得此牌（以此法获得的牌本回合不能使用或打出且不计入手牌上限）并对其造成1点火焰伤害",

  ["@@th_duohuo-turn"] = "堕火",
}

return duohuo